package org.example.rubbish.service.impl;


import org.example.rubbish.entity.InventoryIn;
import org.example.rubbish.entity.InventoryOut;
import org.example.rubbish.mapper.InventoryMapper;
import org.example.rubbish.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class InventoryServiceImpl implements InventoryService {
    @Autowired
    private InventoryMapper inventoryMapper;

    @Override
    public InventoryIn createInventoryIn(InventoryIn inventoryIn) {
        inventoryMapper.insertInventoryIn(inventoryIn);
        return inventoryMapper.selectInventoryInById(inventoryIn.getId());
    }

    @Override
    public InventoryOut createInventoryOut(InventoryOut inventoryOut) {
        inventoryMapper.insertInventoryOut(inventoryOut);
        return inventoryMapper.selectInventoryOutById(inventoryOut.getId());
    }

    @Override
    public InventoryIn getInventoryInById(Long id) {
        return inventoryMapper.selectInventoryInById(id);
    }

    @Override
    public InventoryOut getInventoryOutById(Long id) {
        return inventoryMapper.selectInventoryOutById(id);
    }

    @Override
    public List<InventoryIn> getInventoryInByStationId(Long stationId) {
        return inventoryMapper.selectInventoryInByStationId(stationId);
    }

    @Override
    public List<InventoryIn> getInventoryInByUserId(Long userId) {
        return inventoryMapper.selectInventoryInByUserId(userId);
    }

    @Override
    public List<InventoryIn> getInventoryInByTimeRange(Date startTime, Date endTime) {
        return inventoryMapper.selectInventoryInByTimeRange(startTime, endTime);
    }

    @Override
    public List<InventoryOut> getInventoryOutByStationId(Long stationId) {
        return inventoryMapper.selectInventoryOutByStationId(stationId);
    }

    @Override
    public List<InventoryOut> getInventoryOutByTimeRange(Date startTime, Date endTime) {
        return inventoryMapper.selectInventoryOutByTimeRange(startTime, endTime);
    }
}
